package itbour.onetouchshow.activity.version1_3;

import android.util.Log;

import com.google.gson.Gson;
import com.lsjr.callback.EncryBeanCallBack;
import com.lsjr.utils.HttpUtils;

import java.util.HashMap;
import java.util.List;

import itbour.onetouchshow.base.mvp.BasePresenterImpl;
import itbour.onetouchshow.constants.AppConfig;
import itbour.onetouchshow.constants.AppConst;
import itbour.onetouchshow.utils.L_;

/**
 * Created by Yang on 2018/2/28.
 */

public class ClassifyListPresenter extends BasePresenterImpl<ClassifyListContract.View> implements ClassifyListContract.Presenter {

    public void getDetailsList(ClassifyListActivity activity, List<Integer> ids, String durationKey, String durationValue, String tmplTypeKey, String tmplTypeValue) {
        HashMap<String, Object> stringStringHashMap = new HashMap<>();
        stringStringHashMap.put("setIds", new Gson().toJson(ids));
        //pageNum	是
        stringStringHashMap.put("pageNum", activity.mPageIndex);
        //页码 pageSize
        stringStringHashMap.put("pageSize", AppConst.PAGE_SIZE);
        //   页容量
        stringStringHashMap.put("withTotalPage", 1);
        if (durationKey != null && durationValue != null) {
            stringStringHashMap.put(durationKey, durationValue);
        }
        if (tmplTypeKey != null && tmplTypeValue != null) {
            stringStringHashMap.put(tmplTypeKey, tmplTypeValue);
        }

        Log.e("stringStringHashMap", new Gson().toJson(stringStringHashMap));

        HttpUtils.getInstance().executeGet(AppConfig.GETTMPLSETCONTENT_V1_0, stringStringHashMap, new EncryBeanCallBack() {
            @Override
            protected void onXError(String exception) {
                if (mvpView != null) {
                    mvpView.loadFaild(exception);
                }
            }

            @Override
            protected void onSuccess(String response) {
                L_.i("response  video===" + response);
                if (mvpView != null) {
                    mvpView.loadSucceed(response);
                }
            }
        });
    }
}
